package com.xzqwjw.taskmanager.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.leaderinfo.model.CategoryPosition;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class PositionCategoryDao implements com.leaderinfo.service.OperateDatabaseService {

	private SQLiteDatabase objDB;
	private String strDBFile = "";

	public PositionCategoryDao(String strDBFile) {
		this.strDBFile = strDBFile;
	}

	@Override
	public Map<String, Object> getRecordByAID(int intAID) {
		CategoryPosition objPositionCategory = null;
		Map<String, Object> mapInfo = null;

		objDB = SQLiteDatabase.openOrCreateDatabase(strDBFile, null);

		String strSQL = "SELECT * FROM category_position WHERE aid=?";
		String[] aryArgs = { String.valueOf(intAID) };

		Cursor objCursor = objDB.rawQuery(strSQL, aryArgs);
		if (objCursor.moveToFirst()) {
			objPositionCategory = new CategoryPosition();
			getInfo(objCursor, objPositionCategory);
			mapInfo = new HashMap<String, Object>();
			mapInfo.put("PositionCategory", objPositionCategory);
		}
		objCursor.close();
		objDB.close();
		return mapInfo;
	}

	@Override
	public Map<String, Object> getRecordByBasicID(int intBasicID) {
		return null;
	}

	@Override
	public List<Map<String, Object>> getRecordsByBasicID(int intBasicID) {
		return null;
	}

	@Override
	public List<Map<String, Object>> getAllRecords() {
		return null;
	}

	private void getInfo(Cursor objCursor, CategoryPosition objPositionCategory) {
		objPositionCategory.AID = objCursor.getInt(objCursor
				.getColumnIndex("aid"));
		objPositionCategory.PositionCategory = objCursor.getString(objCursor
				.getColumnIndex("position_category"));
	}

	@Override
	public List<Map<String, Object>> getRecordsByWhere(String strWhere) {
		return null;
	}

}
